package com.ywps.vaas.framework.util

import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.functions.col

object DataFrameUtil {
  /**
   * dataFrame列名重命名（下划线转驼峰）
   * @param dataframe
   */
  def renameColumnsWithUnderlineToHump(dataframe:DataFrame): DataFrame ={
    dataframe.select(dataframe.columns.map(oldColName => col(oldColName).as(ConvertUtil.underlineToHump(oldColName))):_*)
  }

  /**
   * dataFrame列名重命名（驼峰转下划线）
   * @param dataframe
   */
  def renameColumnsWithHumpToUnderLine(dataframe:DataFrame): DataFrame ={
    dataframe.select(dataframe.columns.map(oldColName => col(oldColName).as(ConvertUtil.humpToUnderLine(oldColName))):_*)
  }
}
